<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    @keyframes enter {
      0%{
        transform:translateX(-500px) scale(2);
        opacity: 0;
      }
      50%{
        transform:translateX(-250px) scale(1) rotate(90deg);
        opacity: .6;
      }
      100%{
        transform:translateX(-0) scale(1) rotate(0deg);
        opacity: 1;
      }
    }
    @keyframes leave {
      0%{
        transform:translateY(0) scale(1);
        opacity: 1;
      }
      50%{
        transform:translateY(250px) scale(2) rotate(90deg);
        opacity: .6;
      }
      100%{
        transform:translateY(500px) scale(.3) rotate(0deg);
        opacity: 0;
      }
    }
    .box{
      width: 200px;
      height: 200px;
      background-color: rgb(105, 117, 35);
      margin: 50px auto;
    }
    .ani-enter-active{
      animation: enter 1s;
    }
    .ani-leave-active{
      animation: leave 1s;
    }
  </style>
</head>
<body>
  <div id="app">
    <button @click="isShow = !isShow">
      {{ isShow?'消失':'显示' }}
    </button>
    <transition name="ani">
      <div class="box" v-if="isShow"></div>
    </transition>
  </div>
  <script src="./vue.js"></script>
  <script>
    const vm = new Vue({
      el: '#app',
      data: {
        isShow: true
      }
    })
  </script>
</body>
</html>